<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"
    />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script src="./js/lib.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="">web 内容管理</a>
            <a href="">经销商管理</a>
            <a>
                <cite>添加经销商</cite>
            </a>
        </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);"
            title="刷新">
            <i class="layui-icon" style="line-height:30px">ဂ</i>
        </a>
    </div>
    <div class="x-body">
        <div class="layui-form layui-form-pane">
            <div class="layui-form-item">
                <label for="" class="layui-form-label">
                    <span class="x-red">*</span>经销商-简体
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="agtNameCn" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <label for="" class="layui-form-label">
                    <span class="x-red">*</span>经销商-繁体
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="agtNameTw" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <label for="" class="layui-form-label">
                    <span class="x-red">*</span>经销商-英文
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="agtNameEn" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="" class="layui-form-label">
                    <span class="x-red">*</span>联系方式
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="agtPhone" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <label for="" class="layui-form-label">
                    <span class="x-red">*</span>营业时间
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="openTime" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <label for="" class="layui-form-label">
                    <span class="x-red">*</span>经销商编码（例如A021）
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="agtCode" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="" class="layui-form-label">
                    <span class="x-red">*</span>地址-简体
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="addrCn" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <label for="" class="layui-form-label">
                    <span class="x-red">*</span>地址-繁体
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="addrTw" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <label for="" class="layui-form-label">
                    <span class="x-red">*</span>地址-英文
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="addrEn" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                 <label for="" class="layui-form-label">
                <span class="x-red">*</span>坐标lat(谷歌）
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="lat" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <label for="" class="layui-form-label">
                    <span class="x-red">*</span>坐标lng
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="lng" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label for="" class="layui-form-label">简介-简体</label>
                <div class="layui-input-block">
                    <textarea name="descCn" placeholder="请输入内容" class="layui-textarea" required lay-verify="required"></textarea>
                </div>
                <label for="" class="layui-form-label">简介-繁体</label>
                <div class="layui-input-block">
                    <textarea name="descTw" placeholder="请输入内容" class="layui-textarea" required lay-verify="required"></textarea>
                </div>
                <label for="" class="layui-form-label">简介-英文</label>
                <div class="layui-input-block">
                    <textarea name="descEn" placeholder="请输入内容" class="layui-textarea" required lay-verify="required"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <button class="layui-btn" lay-filter="newAdd" lay-submit>
                    确定新增
                </button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </div>

    <script>
        var aId = Cookies.get('kplus-helmetAdminId');
        var aToken = Cookies.get('kplus-helmetAdminToken');
        layui.use(['layer', 'form'], function (event) { 
            var layer = layui.layer;
            var form = layui.form;
            form.on('submit(newAdd)', function (data) {            
                var agtData = {
                    'aId': aId,
                    'aToken': aToken,
                    'addr': 'cn:' + data.field.addrCn + '|tw:' + data.field.addrTw + '|en:' + data.field.addrEn,
                    'name': 'cn:' + data.field.agtNameCn + '|tw:' + data.field.agtNameTw + '|en:' + data.field.agtNameEn,
                    'phone': data.field.agtPhone,
                    'time': data.field.openTime,
                    'intro': 'cn:' + data.field.descCn + '|tw:' + data.field.descTw + '|en:' + data.field.descEn,
                    'coordinates': data.field.lat + "|" + data.field.lng,
                    'code': data.field.agtCode
                }
                newAdd(agtData)
            })
            //新增传递
            function  newAdd(agtData) { 
                var loadindex1 = layer.load(1, {
                    shade: [0.5, '#000']
                });
                $.ajax({
                    url:bAsEuRl + uRlS.agent,
                    type:'put',
                    data: agtData,
                    success:function(data){
                        if(data.msg.code == 200){
                            layer.close(loadindex1);
                            layer.msg(data.data.msg, {time:2000});
                            location.reload();
                        }else{
                             layer.close(loadindex1);
                            layer.msg(data.msg.msg, { time: 2000 }); 
                        }
                    },
                    error: function(data) {
                        layer.close(loadindex1);
                        layer.msg('系统发生严重错误，请联系维护人员')
                    }
                })
            }

        })

    </script>
</body>

</html>